<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <title>Document</title>
</head>
<body>
<div id="app">
    <div>tel {{ tel }}</div>
    <!-- 模板中使用过滤器 -->
    <div>tel {{ tel | transeTel }}</div>
    <div>price {{ price | transPrice }}</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
<script>
    // 全局过滤器
    Vue.filter('transeTel', function (v) {
        return v.slice(0, 3) + '****' + v.slice(7)
    })
    Vue.filter('transeTel2', function (v) {
        return v + '@@@@@'
    })
    new Vue({
        el: '#app',
        data: {
            tel: "13967554466",
            price: 20,
            allPrice: 40.9
        },
        // 通过filters选项定义过滤器-局部过滤器
        filters: {
            transPrice(v) {
                return v.toFixed(2)
            }
        }
    })
</script>
</body>
</html>